using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System;

namespace MyUtils
{
//	public class InfoSizeExtension : MarkupExtension
//	{
//		public string Invariant { get; private set; }
//
//		public InfoSizeExtension(string invariant)
//		{
//			Invariant = invariant;
//		}
//
//		public override object ProvideValue(IServiceProvider serviceProvider)
//		{
//			return (InfoSize)Invariant;
//		}
//	}

	public class InfoSizeTypeConverter : TypeConverter
	{
		public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
		{
			return sourceType == typeof(string);
		}

		public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
		{
			return destinationType == typeof(string);
		}

		public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
		{
			return (InfoSize)(string)value;
		}

		public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
		{
			return (string)(InfoSize)value;
		}
	}
}